package controlador;

import java.awt.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import vista.VentanaListaUmpire;
import vista.VentanaListaUmpireTabla;
import modelo.Equipo;
import modelo.Liga;
import modelo.Umpire;

public class ControladorVentanaListaUmpire implements ActionListener {

	private VentanaListaUmpire ventanaListaUmpire;
	//private ArrayList<Umpire> umpires;
	private Liga liga;
	
	public ControladorVentanaListaUmpire(Liga liga) {
		super();
		ventanaListaUmpire = new VentanaListaUmpire();
		ventanaListaUmpire.setLocationRelativeTo(null);
		ventanaListaUmpire.setVisible(true);
		this.liga=liga;
		this.cargarListado();
		ventanaListaUmpire.agregarListener(this);
	}
	
	private void cargarListado(){
		if (liga.contarUmpires()>0){
			ArrayList<Umpire> umpires = liga.getUmpires();
			ventanaListaUmpire.setListado(new VentanaListaUmpireTabla(umpires));
		}
		else
			ventanaListaUmpire.mostrarMensaje("No hay umpires registrados");
	}

	public void actionPerformed(ActionEvent e) {
	    ControladorVentanaUmpire controladorVentanaUmpire;
	    if(e.getActionCommand().equalsIgnoreCase("Registrar Umpire")){
	    	ventanaListaUmpire.dispose();
		    controladorVentanaUmpire= new ControladorVentanaUmpire(liga);
	    }
	    else
	    	ventanaListaUmpire.dispose();
	}
	
	/**public ControladorVentanaListaUmpire(ArrayList umpires) {
		super();
		ventanaListaUmpire = new VentanaListaUmpire();
		ventanaListaUmpire.setLocationRelativeTo(null);
		ventanaListaUmpire.setVisible(true);
		this.umpires=umpires;
		this.cargarListado();
		ventanaListaUmpire.agregarListener(this);
	}*/

}
